package milu.file;

import java.io.File;
import java.io.FileFilter;

import org.apache.log4j.Logger;

public class RunCollector {
	final static Logger log = Logger.getLogger(RunCollector.class);

	public static void main(String[] args) {
		String propname = "xpg.import.dir";
		String path = System.getProperty(propname);
		if (path == null) {
			log.warn("Pfad mit " + propname + " angeben.");
			//System.exit(0);
			path = "C:\\MILU\\dev\\XML"; // C:\data\ASV-DS\2009_06_28_09_12-ds ???
		}
		File root = new File(path);
		log.info(root);
		FileFilter ff = new FileFilter() {
			public boolean accept(File f) {
				return f.isDirectory() || f.getName().endsWith(".xml");
			}
		};
		Collector coll = new Collector(root, ff);
		int count = 0;
		boolean sleep = false;
		while (coll.hasNext()) {
			count++;
			log.trace(coll.getCurrentQueueSize() + " " + coll.next());
			if (sleep) {
				try {
					Thread.sleep(300);
				} catch (InterruptedException ex) {
				}
			}
		}
		log.info("Anzahl Dateien: " + count);
	}

}
